package org.hxzon.demo.scala

import java.util._

class DateHelper(number: Int) {
  def days(when: String): Date = {
    var date = Calendar.getInstance();
    when match {
      case "ago" => date.add(Calendar.DAY_OF_MONTH, -number)
      case "from_now" => date.add(Calendar.DAY_OF_MONTH, number)
      case _ => date
    }
    date.getTime()
  }
}

object DateHelper {
  val ago = "ago"
  val from_now = "from_now"
  implicit def converIntToDateHelper(number: Int) = new DateHelper(number)
}